import { defineConfig, loadEnv } from "vite";
import vue from "@vitejs/plugin-vue";
import { resolve } from "path";
// https://vitejs.dev/config/
export default ({ mode }) => {
  const env = loadEnv(mode, process.cwd());

  return defineConfig({
    plugins: [vue()],
    server: {
      host: "0.0.0.0",
      port: 8080,
      open: true,
      proxy: {
        [env.VITE_APP_BASE_API]: {
          target: `http://192.168.20.51:8999`,
          changeOrigin: true,
          rewrite: (path) => path.replace(env.VITE_APP_BASE_API, ""),
        },
      },
      disableHostCheck: true,
    },
    resolve: {
      // 配置路径别名
      alias: {
        "@": resolve(__dirname, "./src"),
      },
    },
  });
};
